package com.yfl.logistics.mapper;

import com.yfl.logistics.pojo.TRole;
import com.yfl.logistics.pojo.TRoleExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface TRoleMapper {
    @Delete({
        "delete from t_role",
        "where role_id = #{roleId,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long roleId);

    @Insert({
        "insert into t_role (role_id, rolename, ",
        "remark, permission_ids)",
        "values (#{roleId,jdbcType=BIGINT}, #{rolename,jdbcType=VARCHAR}, ",
        "#{remark,jdbcType=VARCHAR}, #{permissionIds,jdbcType=VARCHAR})"
    })
    int insert(TRole record);

    @InsertProvider(type=TRoleSqlProvider.class, method="insertSelective")
    int insertSelective(TRole record);

    @SelectProvider(type=TRoleSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="role_id", property="roleId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="rolename", property="rolename", jdbcType=JdbcType.VARCHAR),
        @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR),
        @Result(column="permission_ids", property="permissionIds", jdbcType=JdbcType.VARCHAR)
    })
    List<TRole> selectByExample(TRoleExample example);

    @Select({
        "select",
        "role_id, rolename, remark, permission_ids",
        "from t_role",
        "where role_id = #{roleId,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="role_id", property="roleId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="rolename", property="rolename", jdbcType=JdbcType.VARCHAR),
        @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR),
        @Result(column="permission_ids", property="permissionIds", jdbcType=JdbcType.VARCHAR)
    })
    TRole selectByPrimaryKey(Long roleId);

    @UpdateProvider(type=TRoleSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(TRole record);

    @Update({
        "update t_role",
        "set rolename = #{rolename,jdbcType=VARCHAR},",
          "remark = #{remark,jdbcType=VARCHAR},",
          "permission_ids = #{permissionIds,jdbcType=VARCHAR}",
        "where role_id = #{roleId,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(TRole record);
}